package com.boang.state;

import java.util.concurrent.locks.LockSupport;

/*
  @author: 13813
  @date: 2024/11/27 9:52
*/
public class ThreadStateLockSupportDemo03 {
    public static void main(String[] args) {
        Object lock = new Object();//锁

        Thread t0 = new Thread(new Runnable() {
            @Override
            public void run() {
                LockSupport.park(); //阻塞
                System.out.println("abc");
            }
        });
        t0.start();

        new Thread(new Runnable() {
            @Override
            public void run() {
                synchronized (lock) {
                    System.out.println("def");
                    LockSupport.unpark(t0);//唤醒
                }
            }
        }).start();
    }
}
